from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import QIcon
import sys


def on_submit():
    print("用户名：", edit_username.text())
    print("密码：", edit_password.text())
    print("电话：", edit_phone.text())


if __name__ == '__main__':
    # 1.创建应用程序
    app = QApplication(sys.argv)

    # 2.创建窗口
    w = QWidget()

    w.resize(400, 300)

    # 修改窗口标题
    w.setWindowTitle('表单布局')
    # 创建布局
    layout = QFormLayout(w)

    edit_username = QLineEdit()
    edit_password = QLineEdit()
    edit_password.setEchoMode(QLineEdit.Password)
    edit_phone = QLineEdit()
    # 添加提交按钮
    btn = QPushButton('提交')
    btn.clicked.connect(on_submit)

    layout.addRow("用户名", edit_username)
    layout.addRow("密码", edit_password)
    layout.addRow("电话", edit_phone)
    layout.addRow(btn)

    # 3.显示窗口
    w.show()

    # 4.等待窗口停止
    sys.exit(app.exec())
